package feevale.boteco.view.table;

import java.util.ArrayList;
import java.util.List;

import javax.swing.table.AbstractTableModel;

import feevale.boteco.bean.Cerveja;

public class CervejaTableModel extends AbstractTableModel {

	private List<Cerveja> rows;
    private String[] columns = new String[] {"Cervejas"};
   
    public CervejaTableModel() {
    	rows = new ArrayList<Cerveja>();
    }
   
    public CervejaTableModel(List<Cerveja> cervejas) {
    	rows = cervejas;
    }
   
    @Override
    public int getRowCount() {
    	return rows.size();
    }

    @Override
    public int getColumnCount() {
    	return columns.length;
    }
   
    @Override
    public String getColumnName(int columnIndex) {
    	return columns[columnIndex];
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        Cerveja cerveja = rows.get(rowIndex);
        
        switch (columnIndex) {
        	case 0 : return cerveja.getNome();
        }
        
        return null;
    }
}
